/**
 * // Definition for a Node.
 * function Node(val,children) {
 *    this.val = val;
 *    this.children = children;
 * };
 */

/**
 * @param {Node|null} root
 * @return {number[]}
 */
var postorder = function(root) {
    if(root == null) return []
    const ans = []
    const iter = function(node) {
        if(node.children.length !== 0) {
            for(let i = 0; i < node.children.length; i++) {
                iter(node.children[i])
            }
            ans.push(node.val)
        } else {
            ans.push(node.val)
        }
    }
    return ans
};